<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue路由3</title>
    <script src="../../js/vue3.js"></script>
    <script src="../../js/vue-router.global.js"></script>
    <style>
        #app {
            margin: 5rem auto;
            width: 30%;
        }
        
        * {
            padding: 0;
            margin: 0;
        }
        
        .box {
            border: 1px gray solid;
        }
        
        .row {
            display: flex;
            justify-content: space-around;
        }
        
        a {
            width: 50%;
            background-color: lightgray;
            border: 1px gray solid;
            font-size: 1.2rem;
            text-align: center;
            padding: 1rem;
        }
        
        .content {
            height: 5rem;
            padding: 1rem;
            font-size: 1.5rem;
        }
        
        .router-link-active {
            background-color: brown;
            color: white;
        }
    </style>
</head>

<body>
    <!-- 运行 -->
    <div id="app">
        <div class="box">
            <div class="row">
                <router-link to="/login/star/1">登录</router-link>
                <router-link to="/register/Gwen/2">注册</router-link>
            </div>
            <div class="content">
                <router-view></router-view>
            </div>
        </div>

    </div>
    <!-- 模版 -->
    <template id="login">
        <p>账&emsp;&emsp;号: <input type="text" :value="this.$route.params.username"></p>
        <p>密&emsp;&emsp;码: <input type="text" :value="this.$route.params.password"></p>
    </template>
    <template id="register">
        <p>账&emsp;&emsp;号: <input type="text" :value="this.$route.params.username"></p>
        <p>密&emsp;&emsp;码: <input type="text" :value="this.$route.params.password"></p>
        <p>确认密码: <input type="text" :value="this.$route.params.password"></p>
    </template>
    <script>
        const v_app = Vue.createApp({
            data() {
                return {

                }
            },
        });
        const login = {
            template: "#login",
        }
        const register = {
            template: "#register",
        }
        const routes = [{
            path: "/login/:username/:password",
            component: login
        }, {
            path: "/register/:username/:password",
            component: register
        }, ]
        const router = VueRouter.createRouter({
            history: VueRouter.createWebHashHistory(),
            routes: routes
        });
        v_app.use(router);
        v_app.mount("#app");
    </script>
</body>

</html>